﻿using Basic.WxExtendService.Interface;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;
using WeDonekRpc.Helper.Config;

namespace Basic.WxExtendService.Config
{
    [ClassLifetimeAttr(ClassLifetimeType.SingleInstance)]
    internal class WxConfig : IWxConfig
    {
        private readonly IConfigSection _Section;
        public WxConfig (ISysConfig config)
        {
            this._Section = config.GetSection("basic:wx");
            this._Section.AddRefreshEvent(this._Init);
        }
        private void _Init (IConfigSection section, string name)
        {
            this.DefPlatformAppId = section.GetValue("DefPlatformAppId");
            this.GatewayUri = section.GetValue<Uri>("GatewayUri");
            this.ApplyOverTime = section.GetValue<int>("ApplyOverTime", 600);
        }
        public string DefPlatformAppId { get; private set; }

        public Uri GatewayUri { get; private set; }

        public int ApplyOverTime { get; private set; }
    }
}
